package com.liziba.demo.slice;

import com.liziba.demo.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Button;

public class MainAbilitySlice extends AbilitySlice {
    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        // 加载xml布局
        super.setUIContent(ResourceTable.Layout_ability_main);
        // 这个Id_button，编译器会统一分配一个唯一id，对应ability_main.xml中定义的button
        Button button = (Button) findComponentById(ResourceTable.Id_button);
        // 按钮点击实现跳转
        button.setClickedListener(listener -> present(new SecondAbilitySlice(), new Intent()));
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
